import {basUrl} from '@/common/basUrl.js'
import {getToken} from '@/common/token.js'
export function request(options){
	// HTTPRequest  阿贾克斯  $ajax Jquery  axios
	options.url = basUrl+options.url
	let token = getToken("token")
	console.log("dd",token);
	let optons1 = {
		...options
	}
	if(!options.header.isToken){
		console.log(99);
		if(token){
			optons1.header.Authorization = token
		}
	}else {
		optons1.header ={}
	}
	return new Promise((resovle,reject) => {
		uni.request({
		    ...optons1,
		    success: (res) => {
		        console.log(res.data);
				let code = res.data.code
				if(code == 200){
					
				}else if(code == 401){
					
				}else if(code == 404){
					uni.showToast({
						title:"页面找不到了",
						icon:'error'
					})
				}
				resovle(res.data)
		    },
			fail:(error) =>{
				console.log(error);
				reject(error)
			}
		});
	})
}